<template>
    <div class="tab-bar-item" @click="itemClick">
        <div :style='activeStyle' class="iconfont"><slot name='item-iconfont'></slot></div>
        <div :style='activeStyle' class="text"><slot name='item-text' ></slot></div>
    </div>
</template>

<script>
    export default {
        name: '',
        props:{
            // path是字符串类型 path让外边传进来
            path:String,
            activeColor:{
                type:String,
                default:'#0086f6'
            }
        },
        data () {
            return {
                isTrue:false,
            }
        },
        computed: {
            isActive(){
                return this.$route.path===this.path
            },
            activeStyle(){
                return this.isActive ?{color:this.activeColor}:{}
            }
        },
        methods: {
            itemClick(){
                this.$router.replace(this.path)
            }
        }
    }
</script>

<style scoped lang='less'>
   .tab-bar-item{
       display: flex;
       flex-direction: column;
       justify-content: center;
       align-items: center;
       font-size: 10px;
       .iconfont{
           font-size: 20px;
           margin-bottom: 5px;
       }

    }
</style>
